package com.song.codesandbox;

import java.nio.charset.StandardCharsets;
import java.util.*;

import cn.hutool.core.io.resource.ResourceUtil;
import com.song.codesandbox.model.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class JavaNativeCodeSandBox extends JavaCodeSandBoxTemplate {

    /**
     * 执行代码示例
     *
     * @param args
     */
    public static void main(String[] args) {
        JavaNativeCodeSandBox javaNativeCodeSandBox = new JavaNativeCodeSandBox();

        String code = ResourceUtil.readStr("test/unSafeCode/ReadFileError.java", StandardCharsets.UTF_8);
        ExecuteCodeRequest request = ExecuteCodeRequest.builder()
                .inputList(Arrays.asList("1 2", "3 4"))
                .code(code)
                .language("java")
                .build();

        ExecuteCodeResponse response = javaNativeCodeSandBox.executeCode(request);
    }
}
